<template>
    <basic-container>

        <div style="width:50%;margin-top: 10px;">
            <avue-form ref="form" v-model="objA" :option="optionA"  @submit="submitA">
            </avue-form>
        </div>

    </basic-container>
</template>
<script>
    import{
        getCrossDomainApplication,
        setCrossDomainApplication
    } from "../../api/base/sysSet/crossDomainApplication";
    export default {
        data() {
            return {
                activeName: 'A',
                objA:{},
                objB:{},
                optionA:{
                    emptyBtn:false,
                    labelWidth:'200',
                    labelPosition:'left',
                    column: [{
                        label: "跨域申请条件",
                        prop: "crossApplyCondition",
                        tip:'跨域申请条件',
                        span: 24,
                        rules: [{
                            required: true,
                            message: '请输入跨域申请条件',
                            trigger: 'blur'
                        }]
                    }]
                },


            }
        },
        //页面初始化
        created(){
            this.getData()
        },
        methods: {
            getData(){
                getCrossDomainApplication().then(res=>{
                    if(res.data.code==200){
                        this.objA=res.data.data
                    }else {
                        this.$message({
                            message: res.data.message,
                            type: 'error'
                        })
                    }
                })
            },
            submitA (form,done) {
                var reg=/^\S.*\S$/;
                if(!reg.test(this.objA.crossApplyCondition)){
                    done()
                    this.$message({
                        message:'跨域申请条件首尾不可包含空格',
                        type:'error'
                    })
                    return
                }
                setCrossDomainApplication(this.objA).then(res=>{
                    if(res.data.code==200) {
                        done()
                        this.$message({
                            message:'提交成功',
                            type:'success'
                        })
                        this.getData()
                    }else {
                        done()
                        this.$message({
                            message: res.data.message,
                            type: 'error'
                        })
                    }
                })
            },
        }
    };
</script>
<style>
    h5{
        color: darkred;
        font-weight: bold;
    }
    p{
        line-height: 30px;
    }

</style>